import request from '@/utils/request'
const pay_url = process.env.VUE_APP_PAY_API
/**
 * 创建支付订单
 * http://192.168.88.247:4999/web/#/105/868
 * @param {*} data
 * @returns
 */
export function createOrderApi (data) {
  return request({
    url: '/api/v1/order/create',
    method: 'post',
    data
  })
}
/**
 * 订单支付信息获取
 * http://192.168.88.247:4999/web/#/52/309
 * @param {Object} data
 * @returns
 */
export function getOrderInfoApi (data, headers) {
  return request({
    headers,
    baseURL: pay_url,
    url: '/api/v1/pay',
    method: 'post',
    data
  })
}
/**
 * 获取支付二维码唯一标识
 * http://192.168.88.247:4999/web/#/105/1966
 * @param {Object} data
 * @returns
 */
export function getPrepayCode (data) {
  return request({
    // baseURL: pay_url,
    noMsg: true,
    url: '/api/v1/order/qr_prepay_code',
    method: 'post',
    data
  })
}
/**
 * 根据二维码id获取订单状态
 * http://192.168.88.247:4999/web/#/52/1968
 * @param {Object} data
 * @returns
 */
export function checkCodeStatus (data) {
  return request({
    baseURL: pay_url,
    noMsg: true,
    url: '/api/v1/order/check_qr_order',
    method: 'post',
    data
  })
}
/**
 * 从第三方支付查询实际支付结果，防止通知过久
 * http://192.168.88.247:4999/web/#/52/1969
 * @param {Object} data
 * @returns
 */
export function checkCodeFinish (data) {
  return request({
    baseURL: pay_url,
    url: '/api/v1/order/finish_qr_order',
    method: 'post',
    data
  })
}
/**
 * 订单支付状态检测
 * http://192.168.88.247:4999/web/#/52/308
 * @param {Object} params
 * @returns
 */
export function checkOrderInfo (params) {
  return request({
    baseURL: pay_url,
    url: '/api/v1/check_order',
    method: 'get',
    params
  })
}
